package com.fjwt.gz.proxy.ctrl.activity.stat;

import com.alibaba.fastjson2.JSONObject;
import com.fjwt.gz.core.model.ApiRes;
import com.fjwt.gz.db.entity.StatActivityAgentNumEntity;
import com.fjwt.gz.proxy.ctrl.CommonCtrl;
import com.fjwt.gz.service.impl.StatActivityAgentNumService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 首页活动统计
 */
@RestController
@Slf4j
@RequestMapping("/api/activityStatistics")
public class HomeActivityStatisticsController extends CommonCtrl {
    @Autowired
    StatActivityAgentNumService statActivityAgentNumService;

    @PostMapping("/aggregateQuery")
    public ApiRes aggregateQuery() {
        String agentNo = getValString("agentNo");
        String currentAgentNo = getCurrentAgentNo();
        String s = checkAgentAuth(currentAgentNo, agentNo);
        JSONObject jsonObject = statActivityAgentNumService.aggregateQuery(s);
        return ApiRes.ok(jsonObject);
    }

    @PostMapping("/aggregateQueryFilter")
    public ApiRes aggregateQueryFilter() {
        String agentNo = getValString("agentNo");
        String currentAgentNo = getCurrentAgentNo();
        String s = checkAgentAuth(currentAgentNo, agentNo);
        List<StatActivityAgentNumEntity> one = statActivityAgentNumService.aggregateQueryFilter(s);
        return ApiRes.ok(one);
    }
}
